#include "htf_secure_mem.h"
#include "securec.h" // from libsecurec.a

void* htf_secure_calloc(size_t nmemb, size_t size) {
    void* p = malloc(nmemb * size);
    if (p) memset_s(p, nmemb * size, 0, nmemb * size);
    return p;
}

void htf_secure_memzero(void* p, size_t n) {
    if (p) memset_s(p, n, 0, n);
}

void htf_secure_free(void* p) {
    if (p) {
        htf_secure_memzero(p, malloc_usable_size(p));
        free(p);
    }
}